package com.shop.admin.controller;

import com.shop.admin.aop.Log;
import com.shop.common.core.AjaxResult;
import com.shop.common.enums.FileTypeEnum;
import com.shop.common.util.OSSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

@RestController
@RequestMapping("${app.api-prefix}/upload")
@Api(tags = "上传文件管理")
public class UploadController {

    @Log(title = "上传图片")
    @PostMapping("/image")
    @ApiOperation(value="上传图片")
    public AjaxResult<Map<String, String>> image() {
        return AjaxResult.success(OSSUtil.preUpload(FileTypeEnum.IMAGE.getType()));
    }

    @Log(title = "上传视频")
    @PostMapping("/video")
    @ApiOperation(value="上传视频")
    public AjaxResult<Map<String, String>> video() {
        return AjaxResult.success(OSSUtil.preUpload(FileTypeEnum.VIDEO.getType()));
    }

    @Log(title = "上传音频")
    @PostMapping("/voice")
    @ApiOperation(value="上传音频")
    public AjaxResult<Map<String, String>> voice() {
        return AjaxResult.success(OSSUtil.preUpload(FileTypeEnum.VOICE.getType()));
    }

}
